@extends('index.app')

@section('content')
    <ul class="breadcrumb">
        <li><a href="{{url('/')}}">首页</a></li>
        <li><a href="{{url('/item')}}">失物招领</a></li>
        <li class="active">{{$item->name}}</li>

    </ul>
    <div class="col-sm-9">
        <div class="panel panel-default">
            <div class="panel-heading">
                {{$item->name}} <span class="badge">{{$item->typeName()}}</span>

                <span class="badge">{{$item->status()}}</span>
            </div>
            <div class="panel-body">
                @if($images = $item->images)
                    <div id="item_images" class="carousel slide" data-ride="carousel">
                        <div class="carousel-inner" role="listbox">
                            @foreach($images as $key => $image)
                                <div class="item <?=$key == 0 ? 'active' : ''?>">
                                    <img src="{{$image->url}}" style="width:100%;height:200px;">
                                </div>
                            @endforeach
                        </div>
                        <a class="left carousel-control" href="#item_images" role="button"
                           data-slide="prev">
                            <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                            <span class="sr-only">Previous</span>
                        </a>
                        <a class="right carousel-control" href="#item_images" role="button"
                           data-slide="next">
                            <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                            <span class="sr-only">Next</span>
                        </a>
                    </div>
                    <hr>
                @endif
                <p>{{$item->user->name}} {{$item->findLostTime()}}</p>

                <p>酬金： {{$item->wanted_fee}}元</p>

                <p>{{$item->p_catalog->name . '-' . $item->catalog->name}}</p>

                <p>{{$item->address()}}</p>

                <p>{{$item->describe}}</p>
            </div>
        </div>
        @if(!$item->match)
            <div>
                <a class="btn btn-primary" href="{{url('user/add-item?match_id=' . $item->id)}}">我来认领</a>
            </div><br>
        @elseif($matchItem = $item->matchItem())
            <div class="panel panel-default">
                <div class="panel-heading">
                    {{$matchItem->name}}
                    <span class="badge">认领信息</span>
                </div>
                <div class="panel-body">
                    @if($images = $matchItem->images)
                        <div id="matchItem_images" class="carousel slide" data-ride="carousel">
                            <div class="carousel-inner" role="listbox">
                                @foreach($images as $key => $image)
                                    <div class="item <?=$key == 0 ? 'active' : ''?>">
                                        <img src="{{$image->url}}" style="width:100%;height:200px;">
                                    </div>
                                @endforeach
                            </div>
                            <a class="left carousel-control" href="#matchItem_images" role="button"
                               data-slide="prev">
                                <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                                <span class="sr-only">Previous</span>
                            </a>
                            <a class="right carousel-control" href="#matchItem_images" role="button"
                               data-slide="next">
                                <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                                <span class="sr-only">Next</span>
                            </a>
                        </div>
                        <hr>
                    @endif
                    <p>{{$matchItem->user->name}} {{$matchItem->findLostTime()}}</p>

                    <p>酬金： {{$item->wanted_fee}}元</p>

                    <p>{{$matchItem->p_catalog->name . '-' . $matchItem->catalog->name}}</p>

                    <p>{{$matchItem->address()}}</p>

                    <p>{{$matchItem->describe}}</p>
                </div>
            </div>
        @endif
        <div id="uyan_frame"></div>
        <script type="text/javascript" src="http://v2.uyan.cc/code/uyan.js"></script>
    </div>
    <div class="col-sm-3">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#">最新找到</a></li>
            <li class="pull-right"><a href="{{url('/item?type=find')}}">更多>></a></li>
        </ul>
        <div class="view">
            <ul class="list-group">
                @foreach($findItems as $item)
                    <a class="list-group-item" href="{{url('/item/' . $item->id)}}">
                        <h4 class="list-group-item-heading">{{$item->name}}</h4>
                        {{$item->findLostTime()}}
                    </a>
                @endforeach
            </ul>
        </div>
        <ul class="nav nav-tabs">
            <li class="active"><a href="#">最新发布</a></li>
            <li class="pull-right"><a href="{{url('/item?type=lost')}}">更多>></a></li>
        </ul>
        <div class="view">
            <ul class="list-group">
                @foreach($lostItems as $item)
                    <a class="list-group-item" href="{{url('/item/' . $item->id)}}">
                        <h4 class="list-group-item-heading">{{$item->name}}</h4>
                        {{$item->findLostTime()}}
                    </a>
                @endforeach
            </ul>
        </div>
    </div>
@endsection